#include<stdio.h>
int main()
{
	int a = 0;
	int b = 0;
	int arr1[1000] = { 0 };
	int arr2[1000] = { 0 };
	int arr3[2000] = { 0 };
	scanf_s("%d%d", &a, &b);
	for (int i = 0; i < a; i++)
	{
		scanf_s("%d", &arr1[i]);
	}
	for (int i = 0; i < b; i++)
	{
		scanf_s("%d", &arr2[i]);
	}
	int i = 0;
	int j = 0;
	int t = 0;
	while (i < a && j < b)//!!!!!!
	{
		if (arr1[i] <= arr2[j])
		{
			arr3[t] = arr1[i];
			i++;
		}
		else
		{
			arr3[t] = arr2[j];
			j++;
		}
		t++;
	}
	while (j < b)
	{
		arr3[t] = arr2[j];
		j++;
		t++;
	}
	while (i < a)
	{
		arr3[t] = arr1[i];
		i++;
		t++;
	}
	for (int i = 0; i < a + b; i++)
	{
		printf("%d ", arr3[i]);
	}
	return 0;
}